<%@ page language="java" import="java.util.*,com.njth.dao.*,com.njth.beans.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
			
	CategoryDAO cdao=(CategoryDAO)DaoConfig.getDao(CategoryDAO.class);
	List<Category> cates=cdao.getAllCategory();
	
	Product product=(Product)request.getAttribute("newProduct");
	if(product==null){
		product=new Product();
		product.setCategory(new Category());
		request.setAttribute("newProduct",product);
	}
	
%>

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>南京同虹科贸，打造专业卫浴系统,TOTO专卖，TOTO洁具。</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<link href="<%=basePath%>com/njth/css/style.css" rel="stylesheet"
			type="text/css" />
		<link href="<%=basePath%>com/njth/css/layout.css" rel="stylesheet"
			type="text/css" />

		<script type="text/javascript">
		
		   function   IsNum(theField)
 			{
  			if   (!IsNum2(theField.value))
  			{alert("该区域只能输入数字！");
 			 theField.focus();
  			 theField.value   =   '';}
 			}
 			function   IsNum2(s)
 			{ 
  			var   Number   =   "0123456789.";
  			for   (i   =   0;   i   <   s.length;i++)
         	{       
                //   Check   that   current   character   isn't   whitespace.
                var   c   =   s.charAt(i);
                if   (Number.indexOf(c)   ==   -1)   return   false;
         	}
 			return   true
		
		}
		
		
		
  			function pageSub(){
  	
  			var msg="";
  			var name=document.addpro.productname.value;
  			var categoryid=document.addpro.category.value;
  			if(name==""){
  			msg=msg+"产品名称不能为空！";
  			}
  			if(categoryid<0){
  			msg=msg+"请选择产品类别！";
  			}
  			if(msg.length>0){
  			alert(msg);
  			}else{
  			document.addpro.submit();
  			}
  		}
  	</script>

	</head>

	<body id="page7">
		<div id="main">
			<!-- header -->
			<div id="header">
				<!--Valid flash version 8.0-->
				<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
					codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,24"
					width="980" height="430">
					<param name="movie"
						value="<%=basePath%>com/njth/flash/Header_f8.swf?button=0" />
					<param name="quality" value="high" />
					<param name="menu" value="false" />
					<!--[if !IE]> <-->
					<object data="flash/Header_f8.swf?button=0" width="980"
						height="430" type="application/x-shockwave-flash">
						<param name="quality" value="high" />
						<param name="menu" value="false" />
						<param name="pluginurl"
							value="http://www.macromedia.com/go/getflashplayer" />
						FAIL (the browser should render some flash content, not this).
					</object>
					<!--> <![endif]-->
				</object>
			</div>
			<!-- content -->
			<div id="content">
				<div class="bgd">
					<div class="inner">
						<div class="extra">
							<a href="#"><img alt=""
									src="<%=basePath%>com/njth/images/ing.jpg" /> </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<a href="#"><img alt=""
									src="<%=basePath%>com/njth/images/banner2.jpg" /> </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<a href="#"><img alt=""
									src="<%=basePath%>com/njth/images/banner3.jpg" /> </a>
						</div>
						<div class="article">
							<div class="indent">
								<h2>
									<p align="center">
										添加产品
									</p>
								</h2>
								<form name="addpro" method="post" action="<%=basePath %>servlet/AddProduct" enctype="multipart/form-data">
									<p>
										<font color="#3399cc">请输入产品名称:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<input type="text" name="productname" id="productname" value="${requestScope.newProduct.name }"/></font>
										&nbsp;&nbsp;
									</p>
									<p>
										<font color="#3399cc">请选择产品类别:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<select name="category">
											<option value=-1>
												选择产品类别
											</option>
											<%
											for(Category c:cates){
												
											 %>
											 <option value="<%=c.getId() %>" <%=c.getId()==product.getCategory().getId()?"selecselected='selected'":"" %>>
											 	<%=c.getName() %>
											 </option>
											 <%} %>
											&nbsp;&nbsp;
										</select>
									</p>
									<p>
										<font color="#3399cc">产品定价:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<input type="text" name="price" id="price" size=6
											onblur=IsNum(this) value="${requestScope.newProduct.oprice }"/>
											&nbsp;元</font> &nbsp;&nbsp;
									</p>
									<p>
										<font color="#3399cc">会员定价:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<input type="text" name="mprice" id="mprice" size=6
											onblur=IsNum(this) value="${requestScope.newProduct.sprice}"/>
											&nbsp;元</font> &nbsp;&nbsp;
									</p>
									<p>
										<font color="#3399cc">产品状态信息:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<input type="radio" name="status" value="1" <%=product.getStatus()==1?"checked":"" %>>
											有货&nbsp;&nbsp; </input>
										<input type="radio" name="status" value="0" <%=product.getStatus()==0?"checked":"" %>>
											无货</input></font> &nbsp;&nbsp;
									</p>
									<p>
										<font color="#3399cc">产品图片1:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										&nbsp;&nbsp;&nbsp; <input type="file" name="file1" id="file1"/></font>
										&nbsp;&nbsp;
									</p>
									<p>
										<font color="#3399cc">产品图片2:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										&nbsp;&nbsp;&nbsp; <input type="file" name="file2" id="file2"/></font>
										&nbsp;&nbsp;
									</p>
									<p>
										<font color="#3399cc">产品简介：</font>
									</p>
									<p>
										<font color="#3399cc">用来描述性能
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <textarea rows="6"
											cols="60" name="info" value="${requestScope.newProduct.pinfo }"></textarea></font> &nbsp;&nbsp;
									</p>
									<p align=center>
										<input type="button" value="提交" onclick=pageSub();>
											&nbsp;&nbsp;&nbsp; 
										<input type="reset" value="重填">
									</p>
									<p align="right"><a href="<%=basePath %>com/njth/jsp/pmanager.jsp">返回</a></p>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- footer -->
			<div id="footer">
				<div class="fleft">
					NJTOTO &copy; 2009 | All right
					reserved&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<a href="<%=basePath%>com/njth/jsp/administrator.jsp">登录</a>&nbsp;|
					<a
						href="http://mail.njtoto.com">邮箱</a>
				</div>
				<div class="fright">
					<a href="#"><img alt=""
							src="<%=basePath%>com/njth/images/footer_img1.jpg" /> </a><a
						href="#"><img alt=""
							src="<%=basePath%>com/njth/images/footer_img2.jpg" /> </a><a
						href="#"><img alt=""
							src="<%=basePath%>com/njth/images/footer_img3.jpg" /> </a><a
						href="#"><img alt=""
							src="<%=basePath%>com/njth/images/footer_img4.jpg" /> </a>
				</div>
			</div>
		</div>
	</body>
</html>